Skip to content

[@types/ember-data enhancement] - DS.Store.createRecord() doesn't type check inputProperties #251

Open
@ghost

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementtypes:coreSomething is wrong with the Ember type definitionstypes:core:dataSomething is wrong with the Ember Data type definitions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions