Configurar:
Si está utilizando el código VS (o si ve un tsconfig.jsonarchivo):
Debe agregar la libpropiedad a su tsconfig.jsony luego su editor usará las definiciones de tipo de mecanografiado incluidas y también le dará inteligencia.
Simplemente agregue el "lib": ["esnext", "dom"]a su tsconfig.jsony reinicie VS Code
{
"compilerOptions": {
// ...
"target": "es5",
"lib": ["esnext", "dom"]
// ...
}
}
Ver todas las tsconfig.jsonopciones aquí .
Si está utilizando Visual Studio o MSBuild, incluya esta etiqueta:
<TypeScriptLib>esnext, dom</TypeScriptLib>
Vea todas las opciones y el uso del compilador de mecanografía MSBuild aquí .
Revisa tu trabajo:
Si configuró su proyecto para usar los tipos incorporados y reinició su editor, entonces su tipo resultante se verá así en lugar del tipo anycuando usa Object.assign:

Nota sobre polyfills y compatibilidad con navegadores anteriores:
Tenga en cuenta que si está transfiriendo a ES5 o inferior y está apuntando a IE11, deberá incluir polyfills porque el compilador de mecanografiado no incluirá los polyfills por usted.
Si desea incluir los polyfills (que debería), le recomendaría usar polyfills de core-js.
npm install --save core-js
o
yarn add core-js
Luego, en el punto de entrada de su aplicación (por ejemplo /src/index.ts), agregue la importación core-jsen la parte superior del archivo:
import 'core-js';
Si no está utilizando un administrador de paquetes, puede pegar el siguiente polyfill tomado de MDN en algún lugar de su código que se ejecute antes de usarlo Object.assign.
if (typeof Object.assign != 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, "assign", {
value: function assign(target, varArgs) { // .length of function is 2
'use strict';
if (target == null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}