-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transformer): apply null and warning when property type cannot be…
… identified
- Loading branch information
Showing
4 changed files
with
47 additions
and
3 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
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,26 @@ | ||
import { createMock } from 'ts-auto-mock'; | ||
import { getLogsByCreateMockFileName, UnsupportedTypeLog } from '../utils/log'; | ||
import { InterfacePropFallbackAny } from './untypedProperty.warning.type'; | ||
|
||
describe('Untyped property Warning', () => { | ||
it('should log a warning and apply null to the property', async () => { | ||
const logs: UnsupportedTypeLog[] = await getLogsByCreateMockFileName( | ||
'untypedProperty.warning.test.ts' | ||
); | ||
|
||
createMock<InterfacePropFallbackAny>(); | ||
expect(logs.length).toBe(1); | ||
|
||
expect(logs[0].header).toContain( | ||
'WARNING: Transformer - The transformer could not determine' + | ||
' a property value for prop; ' + | ||
'without a specified type nor an initializer value - it will convert to null' | ||
); | ||
expect(logs[0].created).toMatch( | ||
/created file:\/\/.*untypedProperty\.warning\.test\.ts:[0-9]*:[0-9]*/ | ||
); | ||
expect(logs[0].usedBy).toMatch( | ||
/used by file:\/\/.*untypedProperty\.warning\.type\.ts:[0-9]*:[0-9]*/ | ||
); | ||
}); | ||
}); |
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,4 @@ | ||
export interface InterfacePropFallbackAny { | ||
// eslint-disable-next-line @typescript-eslint/typedef | ||
prop; | ||
} |