TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
Code
// data.json
{
"age": 123,
"username": "Tom",
}
declare const require: any;
// 'age' and 'username' are inffered as any
const { age, username } = require('./data.json')
// wrong syntax
const { age as number, username as string } = require('./data.json')
// can't use destruction, and we cant get warnings when we assert incorrect types
const age: number = require('./data.json').age
const username: string = require('./data.json').username
Expected behavior:
Get the correct types of 'age' and 'username'
Actual behavior:
Thus require syntax can't get the actual types when handling json file.
TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
Code
Expected behavior:
Get the correct types of 'age' and 'username'
Actual behavior:
Thus require syntax can't get the actual types when handling json file.