diff --git a/types/jquery-migrate/index.d.ts b/types/jquery-migrate/index.d.ts new file mode 100644 index 0000000000..b5793a6ec9 --- /dev/null +++ b/types/jquery-migrate/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for jquery-migrate 3.1 +// Project: https://github.com/jquery/jquery-migrate +// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +interface JQueryStatic { + /** + * An array of string warning messages that have been generated by the code on the page, + * in the order they were generated. Messages appear in the array only once, + * even if the condition has occurred multiple times, unless jQuery.migrateReset() is called + * @default [] + */ + migrateWarnings: string[]; + + /** + * Set this property to `true` to prevent console warnings from being generated in the development version.\ + * The `jQuery.migrateWarnings` array is still maintained when this property is set, + * which allows programmatic inspection without console output + * @default false + */ + migrateMute: boolean; + + /** + * Set this property to `false` if you want warnings + * but do not want stack traces to appear on the console. + * @default true + */ + migrateTrace: boolean; + + /** + * Indicates the version of Migrate in use + */ + readonly migrateVersion: string; + + /** + * This method clears the `jQuery.migrateWarnings` array and "forgets" the list of messages + * that have been seen already. + */ + migrateReset(): void; +} diff --git a/types/jquery-migrate/jquery-migrate-tests.ts b/types/jquery-migrate/jquery-migrate-tests.ts new file mode 100644 index 0000000000..66a7d2f9ea --- /dev/null +++ b/types/jquery-migrate/jquery-migrate-tests.ts @@ -0,0 +1,9 @@ +// $ExpectType string[] +jQuery.migrateWarnings; +jQuery.migrateWarnings.length; +jQuery.migrateMute = false; +jQuery.migrateTrace = true; +// $ExpectType void +jQuery.migrateReset(); +// $ExpectType string +jQuery.migrateVersion; diff --git a/types/jquery-migrate/tsconfig.json b/types/jquery-migrate/tsconfig.json new file mode 100644 index 0000000000..3520739dfd --- /dev/null +++ b/types/jquery-migrate/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "DOM" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery-migrate-tests.ts" + ] +} diff --git a/types/jquery-migrate/tslint.json b/types/jquery-migrate/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jquery-migrate/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }