forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ember]: refactor @ember/debug into its own module
- Loading branch information
1 parent
5f7be1f
commit c9b3a76
Showing
7 changed files
with
162 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Ember from 'ember'; | ||
export default class ContainerDebugAdapter extends Ember.ContainerDebugAdapter { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Ember from 'ember'; | ||
|
||
export default class DataAdapter extends Ember.DataAdapter {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { registerDeprecationHandler, runInDebug, warn, assert, debug, registerWarnHandler } from '@ember/debug'; | ||
import ContainerDebugAdapter from '@ember/debug/container-debug-adapter'; | ||
import DataAdapter from '@ember/debug/data-adapter'; | ||
|
||
/** | ||
* @ember/debug tests | ||
*/ | ||
runInDebug(); // $ExpectError | ||
let x = runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void | ||
|
||
// Log a warning if we have more than 3 tomsters | ||
const tomsterCount = 2; | ||
warn('Too many tomsters!'); // $ExpectType void | ||
warn('Too many tomsters!', tomsterCount <= 3); // $ExpectType void | ||
warn('Too many tomsters!', tomsterCount <= 3, { id: 'ember-debug.too-many-tomsters' }); // $ExpectType void | ||
|
||
debug(); // $ExpectError | ||
debug('Too many tomsters!'); // $ExpectType void | ||
debug('Too many tomsters!', 'foo'); // $ExpectError | ||
|
||
// Test for truthiness | ||
const str = 'hello'; | ||
assert('Must pass a string', typeof str === 'string'); // $ExpectType void | ||
|
||
// Fail unconditionally | ||
assert('This code path should never be run'); // $ExpectType void | ||
|
||
// next is not called, so no warnings get the default behavior | ||
registerWarnHandler(); // $ExpectError | ||
registerWarnHandler(() => {}); // $ExpectType void | ||
registerWarnHandler((message, {id, next}) => { // $ExpectType void | ||
message; // $ExpectType string | ||
id; // $ExpectType string | ||
next; // $ExpectType () => void | ||
}); | ||
|
||
// next is not called, so no warnings get the default behavior | ||
registerDeprecationHandler(); // $ExpectError | ||
registerDeprecationHandler(() => {}); // $ExpectType void | ||
registerDeprecationHandler((message, {id, next, until}) => { // $ExpectType void | ||
message; // $ExpectType string | ||
id; // $ExpectType string | ||
until; // $ExpectType string | ||
next; // $ExpectType () => void | ||
}); | ||
|
||
/** | ||
* @ember/debug/data-adapter tests | ||
*/ | ||
|
||
const da = new DataAdapter(); // $ExpectType DataAdapter | ||
const da2 = DataAdapter.create(); // $ExpectType DataAdapter | ||
|
||
da.containerDebugAdapter; // $ExpectType any | ||
da.acceptsModelName; // $ExpectType any | ||
da.getFilters; // $ExpectType () => any[] | ||
da.watchModelTypes(() => ({}), () => ({})); // ExpectType (...args: any[]) => any | ||
da.watchRecords('model:book', () => ({}), () => ({}), () => ({})); // ExpectType (...args: any[]) => any | ||
|
||
/** | ||
* @ember/debug/container-debug-adapter tests | ||
*/ | ||
|
||
const cda = new ContainerDebugAdapter(); // $ExpectType ContainerDebugAdapter | ||
const cda2 = ContainerDebugAdapter.create(); // $ExpectType ContainerDebugAdapter | ||
|
||
cda.catalogEntriesByType('service'); // $ExpectType string[] | ||
cda.canCatalogEntriesByType('service'); // $ExpectType boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Type definitions for @ember/debug 3.0 | ||
// Project: http://emberjs.com/ | ||
// Definitions by: Mike North <https://github.com/mike-north> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.8 | ||
|
||
import Ember from 'ember'; | ||
export const assert: typeof Ember.assert; | ||
export const debug: typeof Ember.debug; | ||
export const inspect: typeof Ember.inspect; | ||
export const registerDeprecationHandler: typeof Ember.Debug.registerDeprecationHandler; | ||
export const registerWarnHandler: typeof Ember.Debug.registerWarnHandler; | ||
export const runInDebug: typeof Ember.runInDebug; | ||
export const warn: typeof Ember.warn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"lib": [ | ||
"es6", | ||
"dom" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"paths": { | ||
"@ember/debug": ["ember__debug"], | ||
"@ember/debug/*": ["ember__debug/*"] | ||
}, | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"data-adapter.d.ts", | ||
"container-debug-adapter.d.ts", | ||
"ember__debug-tests.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"extends": "dtslint/dt.json", | ||
"rules": { | ||
// Heavy use of Function type in this older package. | ||
"ban-types": false, | ||
"jsdoc-format": false, | ||
"no-misused-new": false, | ||
|
||
// these are disabled because of rfc176 module exports | ||
"strict-export-declare-modifiers": false, | ||
"no-single-declare-module": false, | ||
"no-declare-current-package": false, | ||
"no-self-import": false, | ||
|
||
// We use interfaces in a number of places to express things (including | ||
// mixins in particular, but also including extending a global | ||
// interface) which TS currently can't express correctly. | ||
"no-empty-interface": false, | ||
|
||
"no-duplicate-imports": false, | ||
"no-unnecessary-qualifier": false, | ||
"prefer-const": false, | ||
"no-void-expression": false, | ||
"only-arrow-functions": false, | ||
"no-submodule-imports": false, | ||
|
||
// false positives | ||
"unified-signatures": false | ||
} | ||
} |