
Description
ember-cli: 3.3.0
node: 8.11.3
os: linux x64
TypeScript 2.9.2
My tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"allowJs": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noEmitOnError": false,
"noEmit": true,
"inlineSourceMap": true,
"inlineSources": true,
"baseUrl": ".",
"module": "es6",
"paths": {
"my-app/tests/": [
"tests/"
],
"my-app/": [
"app/"
],
"": [
"types/"
]
}
},
"include": [
"app",
"tests",
"types"
]
}
My tslint.json
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended",
"tslint-config-prettier"
],
"rules": {
"arrow-parens": [true, "ban-single-arg-parens"],
"cyclomatic-complexity": [true, 7],
"forin": false,
"indent": [true, "spaces", 2],
"interface-name": false,
"max-file-line-count": [true, 500],
"member-ordering": [true, {
"order": [
"public-static-field",
"public-static-method",
"public-instance-field",
"public-constructor",
"public-instance-method",
"protected-static-field",
"protected-static-method",
"protected-instance-field",
"protected-constructor",
"protected-instance-method",
"private-static-field",
"private-static-method",
"private-instance-field",
"private-constructor",
"private-instance-method"
]
}],
"no-console": false,
"no-empty": [true, ["allow-empty-catch", "allow-empty-functions"]],
"object-literal-sort-keys" : false,
"quotemark": [true, "single", "avoid-escape", "avoid-template"],
"semicolon": [true, "never"],
"trailing-comma": [true, "never"],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"]
}
}
How to reproduce?
Use DS.Store.createRecord()
to create a new record and pass inputProperties
that don't exist on the DS.Model
subclass:
this.store.createRecord('post', { attributeThatDoesNotExist: 'value' })
What did you expect to see?
Expectation is to get the same compiler errors as generated from the following code:
const post = this.store.createRecord('post')
post.setProperties({ attributeThatDoesNotExist: 'value' })
What happened instead?
There are no type errors emitted when createRecord()
is called with invalid properties or with values of the incorrect type.
Activity
mike-north commentedon Sep 4, 2018
Fix is:
Change this
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/034c9126166528c659935f624b17b911ae5b6b15/types/ember-data/index.d.ts#L1013-L1016
to
This might mean we should expose some of
@types/ember
's utility types via a ghost module so that they may be consumed in libs like@types/ember-data
.[-][bug] - DS.Store.createRecord() doesn't type check inputProperties[/-][+][@types/ember-data bug] - DS.Store.createRecord() doesn't type check inputProperties[/+][-][@types/ember-data bug] - DS.Store.createRecord() doesn't type check inputProperties[/-][+][@types/ember-data enhancement] - DS.Store.createRecord() doesn't type check inputProperties[/+]mike-north commentedon Sep 6, 2018
flagging this as an enhancement because the request is for additional type checking that doesn't currently exist (as opposed to TS getting in the way and blocking you from doing things)
chriskrycho commentedon Sep 28, 2023
Leaving this open at present as I don't know whether it has changed in the interval (I don't expect so)… but the preferred path forward here is almost certainly going to be the exposing the significantly-different design path Ember Data has taken in the intervening years via types shipped from Ember Data directly.